# 用户模块下的蓝图，包括用户模块的所有资源

from flask import Blueprint
from flask_restful import Api

from Shopping.resources.user.user_resource import Shopping_User, User_SMS_Send, AuthorizationCodeResource, \
    RegisterUserResource, UserLoginResource, IsExistPhoneResource, UserLoginOutResource
from comment.utils.output import output_json

user_bp = Blueprint('users', __name__,url_prefix='/user')

user_Api = Api(user_bp)#创建蓝图中的资源Api

# #在当前用户模块中添加请求钩子
# user_bp.before_request()

# 使用我们自定义的JSON，替代装饰器的写法
user_Api.representation('application/json')(output_json)

# 加载当前模块的资源
    #测试
user_Api.add_resource(Shopping_User, '/hello', endpoint='user')
    #发送验证码
user_Api.add_resource(User_SMS_Send, '/sms', endpoint='sms')
    #校验验证码
user_Api.add_resource(AuthorizationCodeResource, '/authorization', endpoint='authorization')
    #注册
user_Api.add_resource(RegisterUserResource, '/register', endpoint='register')
    #登录
user_Api.add_resource(UserLoginResource, '/login', endpoint='login')
    #登出
user_Api.add_resource(UserLoginOutResource, '/loginOut', endpoint='loginOut')
    #判断手机号是否注册
user_Api.add_resource(IsExistPhoneResource, '/isExist', endpoint='isExist')
